<div id="tb<?php echo $uniqid;?>">
    <table cellspacing="0" cellpadding="0">
        <tbody>
        <tr>
            <td>
                <SELECT id='dianpuGoodsStatus' onchange="dianpuGoodsSearch();" class="textbox-text validatebox-text">
                    <OPTION value="">全部状态</OPTION>
                    <OPTION value="" disabled="disabled">----------</OPTION>
                    <OPTION value="up">已上架</OPTION>
                    <OPTION value="down">已下架</OPTION>
                </SELECT>
            </td>
            <td>
                <select id="dianpuGoodsKeywordsType" class="forminput inputstyle textbox-text validatebox-text" style="width:120px; border-color: #cccccc !important;">
                    <option value="dianpu_id">店铺ID</option>
                    <option value="member_id">管理员ID</option>
                    <option value="member_phone">管理员电话</option>
                    <option value="goods_id">商品ID</option>
                </select>
                <input id="dianpuGoodsKeywords" style="width:120px" placeholder="输入搜索内容" type="text"
                       class="easyui-input textbox"></td>
            <td><a href="javascript:void(0);" onclick="dianpuGoodsSearch();"
                   class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span
                    class="l-btn-text">查询</span></span></a></td>
            <td>
                <div class="datagrid-btn-separator"></div>
            </td>
            <td><a href="javascript:void(0);" onclick="dianpuGoodsReload();"
                   class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span
                    class="l-btn-text">重载</span></span></a></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="con" style="-moz-user-select:none;">
    <table id="dianpuGoodsTable"></table>
</div>
<div id="dianpuGoodsdlg" class="easyui-dialog" style="width:720px; height:460px;" title="信息框" closed="true"></div>
<script>
    var dianpuGoodsReload = function () {
        $("#dianpuGoodsTable").datagrid('load');
    };
    var dianpuGoodsSearch = function (id) {
        var height = $(window).height() - $(".top").height() - 46;//表格高度
        var width = $(window).width() - $(".leftmenu").width() - 8;
        $("#dianpuGoodsTable").datagrid({
            title: '商品管理',
            width: width,
            height: height,//高度
            singleSelect: true,//如果为true，则只允许选择一行
            striped: true,//是否显示斑马线效果。
            rownumbers: false,//如果为true，则显示一个行号列。
            pagination: true,//是否显示分页
            pageSize: 15,
            pageList: [15, 30, 40, 50],
            method: 'post',
            sortName: 'weigh',
            sortOrder: 'desc',
            url: '/admin/dianpu_goods/index',
            queryParams: {
                keywords_type: $('#dianpuGoodsKeywordsType').val(),
                keywords: $('#dianpuGoodsKeywords').val(),
                status:  $('#dianpuGoodsStatus').val(),
            },
            fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
            nowrap: false,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
            selectOnCheck: false,
            checkOnSelect: true,
            toolbar: '#tb<?php echo $uniqid;?>',
            rowStyler: function (index, row) {
                if (row.status == 'down') {
                    return 'color:#999;';
                }
            },
            columns: [[
                {field: 'id', title: 'ID', width: fixWidth(5), sortable: true},
                {
                    field: 'title', title: '名称', width: fixWidth(20), formatter: function (value, rowData, rowIndex) {
                        return '<div style="display: flex;align-items: center;">' +
                            '<img src="' + rowData.image + '?imageView2/1/w/60/h/60" style="height:60px;width:60px;border-radius: 5px;border:#dfdfdf 1px solid;">' +
                            '<div>' + value + (rowData.is_sku ? '<br>（多规格）' : '') + (rowData.deleted_at ? '<br><span style="color: red">（已删除）</span>' : '') + '</div></div>';
                    }
                },
                {field: 'dianpu', title: '店铺', width: fixWidth(10), formatter:function (value) {
                        if(value){
                            return value.name;
                        }else{
                            return '---';
                        }
                    }},
                {field: 'status', title: '状态', width: fixWidth(5), align: 'center', formatter(value, rowData){
                        return value === 'up' ? '已上架' : '已下架';
                    }},
                {field: 'price', title: '价格', width: fixWidth(5), align: 'center', sortable: true},
                {field: 'sales', title: '销量', width: fixWidth(5), align: 'center', sortable: true},
                {field: 'views', title: '浏览量', width: fixWidth(5), align: 'center', sortable: true},
                {field: 'stock', title: '库存', width: fixWidth(5), align: 'center', sortable: true},
                {field: 'updated_at', title: '更新时间', width: fixWidth(5), align: 'center', sortable: true},
                {field: 'weigh', title: '排序', width: fixWidth(5), align: 'center', sortable: true},
            ]]
        });
    };
    dianpuGoodsSearch();
    onDatagridResize("#dianpuGoodsTable");
</script>
